import java.util.ArrayList;
import java.util.List;
import java.util.Scanner ;
interface IntegerStack{
	Integer push(Integer item) ;
	Integer pop() ;
	Integer peek() ;
	boolean empty() ;
	int size() ;
}
class ArrayListIntegerStack implements IntegerStack{
	ListInteger arrlist = new ArrayListInteger() ;
	public Integer push(Integer item)
	{
		if(item == null)
			return null ;
		arrlist.add(item) ;
		return item ;
	}
	public Integer pop()
	{
		if(arrlist.size() == 0)
			return null ;
		return arrlist.remove(arrlist.size() - 1 ) ;
	}
	public Integer peek()
	{
		if(arrlist.size() == 0)
			return null ;
		return arrlist.get(arrlist.size()-1) ;
	}
	@Override
	public boolean empty() {
		return (arrlist.size() == 0) ;
	}
	@Override
	public int size() {
		return arrlist.size() ;
	}
	@Override
	public String toString() {
		return  arrlist.toString();
	}
	
	
}
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in) ;
		ArrayListIntegerStack arrstack = new ArrayListIntegerStack() ;
		int m = sc.nextInt() ;
		for (int i = 0; i  m; i++) {
			int n = sc.nextInt() ;
			System.out.println(arrstack.push(n));
		}
		System.out.println(arrstack.peek() + ,+arrstack.empty()+,+arrstack.size());
		System.out.println(arrstack);
		int x = sc.nextInt() ;
		for (int i = 0; i  x; i++) {
			System.out.println(arrstack.pop());
		}
		System.out.println(arrstack.peek() + ,+arrstack.empty()+,+arrstack.size());
		System.out.println(arrstack);
		sc.close();
	}
		
}